<!DOCTYPE html>
<html class="x-admin-sm">
	<head>
		<meta charset="UTF-8">
		<title>欢迎页面-X-admin2.2</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="stylesheet" href="../../css/font.css">
		<link rel="stylesheet" href="../../css/xadmin.css">
		<script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="../../js/xadmin.js"></script>
		<script src="../../js/base.js" type="text/javascript" charset="utf-8"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
						            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
						            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
						        <![endif]-->
								
		<style type="text/css">
			.layui-form-label{
				width: 100px;
			}
			.layui-input-block{
				margin-left: 130px;
			}
		</style>
	</head>

	<body>
		<div class="layui-fluid">
			<div class="layui-row">
				<form class="layui-form" lay-filter="example">
					<div class="layui-form-item">
						
						<div class="layui-form-item">
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>BSC1级分类
							</label>
							<div class="layui-input-inline">
								<select lay-filter="type_2" id="type_2" name="type_2" lay-verify="required" lay-search="">

								</select>
								
							</div>
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>BSC2级分类
							</label>
							<div class="layui-input-inline">
								<select lay-filter="type_3" id="type_3" name="type_3" lay-verify="required" lay-search="">
								
								</select>
							</div>
						</div>
						<div class="layui-form-item">
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>级别:
							</label>
							<div class="layui-input-inline">
								
								<select lay-filter="type_1" id="type_1" name="type_1" lay-verify="required" lay-search="">
							
								</select>
							</div>
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>表达式</label>
							<div class="layui-input-inline">
								
								<select lay-filter="isexpress" id="isexpress" name="isexpress" lay-verify="required" lay-search="">
									<option value="1">是</option>
									<option value="0">否</option>
								</select>
							</div>
							
						</div>
						<div class="layui-form-item">
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>指标代码</label>
							<div class="layui-input-inline">
								<input type="text" id="guide_code" disabled="disabled" name="guide_code" required="" autocomplete="off" class="layui-input">
							</div>
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>指标名称</label>
							<div class="layui-input-inline">
								<input type="text" id="guide_name" name="guide_name" required="" autocomplete="off" class="layui-input">
							</div>
						</div>
						
						
						<div class="layui-form-item">
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>指标表达式</label>
							<div class="layui-input-block">
								<textarea rows="" cols="" id="guide_express" name="guide_express" placeholder="请输入指标表达式" class="layui-textarea"></textarea>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>停用状态</label>
							<div class="layui-input-inline">
								<select lay-filter="ispage" id="ispage" name="ispage" lay-verify="required" lay-search="">
									<option value="1">是</option>
									<option value="0">否</option>
								</select>
							</div>
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>高优指标</label>
							<div class="layui-input-inline">
								<select lay-filter="ishighguide" id="ishighguide" name="ishighguide" lay-verify="required" lay-search="">
									<option value="1">是</option>
									<option value="0">否</option>
								</select>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label for="L_username" class="layui-form-label">
								<span class="x-red">*</span>综合评价指标</label>
							<div class="layui-input-inline">
								<select id="issel" name="issel" class="layui-input">
									<option value="1">是</option>
									<option value="0">否</option>
								</select>
								
							</div>
							<div class="layui-input-inline">
								<label for="L_username" class="layui-form-label">
									<span class="x-red"></span></label>
								<button class="layui-btn select" lay-filter="add" lay-submit=""><i class="layui-icon"></i>添加</button>
							</div>
							
						</div>
					</div>
				</form>
			</div>
		</div>
		<script>
			layui.use(["form", "layer", "laydate"],
				function() {
					$ = layui.jquery;
					var form = layui.form,
						layer = layui.layer,
						laydate = layui.laydate;

					laydate.render({
						elem: '#dept_date',
						type: 'datetime'
					});
					
					form.on('select(isexpress)', function(adata) {
						var value = adata.value;
						if(value == 0)
						{
							$("#guide_express").val("");
							$("#guide_express").attr("disabled",true);
						}
						if(value == 1)
						{
							$("#guide_express").attr("disabled",false);
						}
					});
					
					$.post(root + "Zhibiaoweihu/get_jxgl_guide_organ_class_dict_list", {},
						function(data) {

							for (var i = 0; i < data.data.length; i++) {
								$('#type_1').append("<option value='" + data.data[i].organ_class_code + "'>" + data.data[i].organ_class_name +
									"</option>");
							}

							form.render('select');

							form.on('select(type_1)', function(adata) {
								get_code();
							});

						}
					);
					
					

					$.post(root + "Zhibiaoweihu/get_jxgl_guide_bsc_class_dict_list", {
							type: 1
						},
						function(data) {

							for (var i = 0; i < data.data.length; i++) {
								$('#type_2').append("<option value='" + data.data[i].bsc_class_code + "'>" + data.data[i].bsc_class_name +
									"</option>");
							}

							form.render('select');

							$.post(root + "Zhibiaoweihu/get_jxgl_guide_bsc_class_dict_list", {
									type: 2,
									code: $('#type_2').val()
								},
								function(data) {
									$('#type_3').empty();
									for (var i = 0; i < data.data.length; i++) {
										$('#type_3').append("<option value='" + data.data[i].bsc_class_code + "'>" + data.data[i].bsc_class_name +
											"</option>");
									}

									form.render('select');
									get_code();
									form.on('select(type_3)', function(adata) {
										get_code();
									});

								}
							);

							form.on('select(type_2)', function(adata) {

								$.post(root + "Zhibiaoweihu/get_jxgl_guide_bsc_class_dict_list", {
										type: 2,
										code: $('#type_2').val()
									},
									function(data) {
										$('#type_3').empty();
										for (var i = 0; i < data.data.length; i++) {
											$('#type_3').append("<option value='" + data.data[i].bsc_class_code + "'>" + data.data[i].bsc_class_name +
												"</option>");
										}

										form.render('select');
										get_code();
									}
								);

							});

						}
					);

					//监听提交
					form.on("submit(add)",
						function(data) {
							console.log(data.field);

							$.post(root + "Zhibiaoweihu/add_one",
								data.field,
								function(data) {
									if (data.code == 0) {
										layer.alert(data.msg, {
											icon: 6
										});

										xadmin.close();

										// 可以对父窗口进行刷新 
										xadmin.father_reload();
									} else {
										layer.alert(data.msg, {
											icon: 2
										});
									}
								});

							return false;
						});

					function get_code() {
						$.post(root + "Zhibiaoweihu/get_code", {
								type_1: $('#type_1').val(),
								type_2: $('#type_2').val(),
								type_3: $('#type_3').val()
							},
							function(data) {

								$("#guide_code").val(data.data);
							}
						);
					}

				});
		</script>
		<script>
			var _hmt = _hmt || [];
			(function() {
				var hm = document.createElement("script");
				hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
				var s = document.getElementsByTagName("script")[0];
				s.parentNode.insertBefore(hm, s);
			})();
		</script>
	</body>

</html>
